package com.punai.customer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.enums.BusinessType;
import com.punai.customer.domain.CusLinkSubpkCategory;
import com.punai.customer.service.ICusLinkSubpkCategoryService;
import com.punai.common.utils.poi.ExcelUtil;
import com.punai.common.core.page.TableDataInfo;

/**
 * 工序费用项关联类别Controller
 * 
 * @author zxw
 * @date 2022-12-04
 */
@RestController
@RequestMapping("/cus/subpkLinkCategory")
public class CusLinkSubpkCategoryController extends BaseController
{
    @Autowired
    private ICusLinkSubpkCategoryService cusLinkSubpkCategoryService;

    /**
     * 查询工序费用项关联类别列表
     */
    @PreAuthorize("@ss.hasPermi('cus:subpkLinkCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(CusLinkSubpkCategory cusLinkSubpkCategory)
    {
        startPage();
        List<CusLinkSubpkCategory> list = cusLinkSubpkCategoryService.selectCusLinkSubpkCategoryList(cusLinkSubpkCategory);
        return getDataTable(list);
    }

    /**
     * 获取工序费用项关联类别详细信息
     */
    @PreAuthorize("@ss.hasPermi('cus:subpkLinkCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(cusLinkSubpkCategoryService.selectCusLinkSubpkCategoryById(id));
    }

    /**
     * 新增工序费用项关联类别
     */
    @PreAuthorize("@ss.hasPermi('cus:subpkLinkCategory:add')")
    @Log(title = "工序费用项关联类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CusLinkSubpkCategory cusLinkSubpkCategory)
    {
        return toAjax(cusLinkSubpkCategoryService.insertCusLinkSubpkCategory(cusLinkSubpkCategory));
    }

    /**
     * 修改工序费用项关联类别
     */
    @PreAuthorize("@ss.hasPermi('cus:subpkLinkCategory:edit')")
    @Log(title = "工序费用项关联类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CusLinkSubpkCategory cusLinkSubpkCategory)
    {
        return toAjax(cusLinkSubpkCategoryService.updateCusLinkSubpkCategory(cusLinkSubpkCategory));
    }

    /**
     * 删除工序费用项关联类别
     */
    @PreAuthorize("@ss.hasPermi('cus:subpkLinkCategory:remove')")
    @Log(title = "工序费用项关联类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(cusLinkSubpkCategoryService.deleteCusLinkSubpkCategoryByIds(ids));
    }
}
